﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SyndicateBusiness.Classes;
using SyndicateDAO.DatabaseObject;

namespace BigLotterySyndicate
{
    public partial class PlayerSite : BaseMasterPage
    {
        private BusinessFacade _BusinessFacade = new BusinessFacade();
        public BusinessFacade BusinessFacade
        {
            get { return _BusinessFacade; }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (DesignMode)
                return;
        }


        public bool IsUserLoggedIn
        {
            get
            {
                return BusinessFacade.UserBL.IsLoggedIn;
            }
        }

        public user LoggedInUser
        {
            get
            {
                return BusinessFacade.UserBL.LoggedInUser;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsUserLoggedIn)
            {
                //all ok
                if (!this.LoggedInUser.isActive)
                {
                    String strBackUrl = Page.Request.Url.ToString();

                    this.Page.Response.Redirect("/MyAccount/SetUp.aspx?back=" + Server.UrlEncode(strBackUrl));
                }
            }
            else
            {
                String strBackUrl = Page.Request.Url.ToString();

                this.Page.Response.Redirect("/Login/?back=" + Server.UrlEncode(strBackUrl));
            }
        }

        public void SetTopMenuTab(BigLotterySyndicate.MyAccount.Controls.TopNav.AdminNavSection section)
        {
            this.TopNav.NavSelectedSection = section;
        }

        protected string PrintUserName()
        {
            if (IsUserLoggedIn)
                return this.LoggedInUser.username;
            else
                return "";
        }
    }
}